// 引用http
import http from 'axios'

const host = 'service'

// API方法

// 数据库
let apiMysql = (name, is) => {
    return http({
        method: 'GET',
        url: host + '/mysql/mysql.php?name=' + name + '&is=' + is
    })
}
// 数据表
let apiTable = (name, is) => {
    return http({
        method: 'GET',
        url: host + '/mysql/table.php?name=' + name + '&is=' + is
    })
}

// ==================================================

// 注册
let apiRegister = (params) => {
    return http({
        method: 'POST',
        url: host + '/register/index.php',
        data: params
    })
}
// 登入
let apiLogin = (params) => {
    return http({
        method: 'POST',
        url: host + '/login/index.php',
        data: params
    })
}
// 退出登入
let apiExit = () => {
    return http({
        method: 'GET',
        url: host + '/login/exit.php'
    })
}

// ==================================================

// 收支列表及统计
let apiIncspeList = (params) => {
    return http({
        method: 'GET',
        url: host + '/api/incspe-list.php',
        params
    })
}
// 最近记账
let apiRecently = (params) => {
    return http({
        method: 'get',
        url: host + '/api/incspe-recently.php',
        params
    })
}
// 获取类型
let apiType = (params) => {
    return http({
        method: 'GET',
        url: host + '/api/get-type.php',
        params
    }) 
}
// 修改/添加/删除类别
let apiAlterType = (params) => {
    return http({
        method: 'POST',
        url: host + '/api/alter-type.php',
        data: params
    })
}
// 记帐
let apiIncspe = (params) => {
    return http({
        method: 'POST',
        url: host + '/api/incspe.php',
        data: params
    })
}
// 按最小单位统计
let apiIncspeStatistics = (params) => {
    return http({
        method: 'GET',
        url: host + '/api/incspe-statistics.php',
        params
    })
}
// 按类型统计
let apiTypeStatistics = (params) => {
    return http({
        method: 'GET',
        url: host + '/api/incspe-type.php',
        params
    })
}
// 我的资金
let apiMyMoney = (params) => {
    return http({
        method: 'get',
        url: host + '/api/my-money.php',
        params
    })
}

// 导出
export {
    apiMysql,
    apiTable,

    apiRegister,
    apiLogin,
    apiExit,

    apiIncspeList,
    apiRecently,
    apiType,
    apiAlterType,
    apiIncspe,
    apiIncspeStatistics,
    apiTypeStatistics,
    apiMyMoney
}